package view;
import controller.Controller;
import memory.spel.R;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.view.MenuItem;
import android.widget.Toast;

public class Preferences extends PreferenceActivity {
	
	private static final int CAMERA_PIC_REQUEST = 1337;
	
	 @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);
        
         //geef het aantal tegels door aan het spel
         Controller.getInstance().setContext(getApplicationContext());
         Controller.getInstance().getSpel().setAantalTegels(getAantalTegels());
	 }
	/**
	 * Get aantal tegels van de preferences
	 * @return
	 */
	private int getAantalTegels() {
		SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
	    return sharedPrefs.getInt("aantaltegelspref", Controller.getInstance().defaultAantalTegels);
	}
	 
	 @Override
	 public boolean onOptionsItemSelected(MenuItem item) { 
	     switch (item.getItemId()) {
		     case R.id.spelZelf:
		         break;
		     case R.id.fotoAlbum:
		         break;
	     	case R.id.fotoCamera:
		         //schakel de foto camera in
     			Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
     			startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
     			Toast.makeText(getApplicationContext(), "Jjaja", 200);
		         break;
	     }
	     return true;
	 }
	 
	 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	    if (requestCode == CAMERA_PIC_REQUEST) {
	    	//Bitmap thumbnail = (Bitmap) data.getExtras().get("data");  
	    }
	 }
}
